package mjc.egg;
import mjc.tds.*;
import mjc.type.*;
import mjc.gc.*;
import mjc.compiler.*;
import java.util.*;
import mg.egg.eggc.compiler.libjava.lex.*;
import mg.egg.eggc.compiler.libjava.*;
import mg.egg.eggc.compiler.libjava.problem.IProblem;
import java.util.Vector;
import java.util.List;
import java.util.ArrayList;
public class S_DEF_MJAVA implements IDstNode {
LEX_MJAVA scanner;
  S_DEF_MJAVA() {
    }
  S_DEF_MJAVA(LEX_MJAVA scanner) {
    this.scanner = scanner;
    offset = 0;
    length = 0;
    this.att_scanner = scanner;
    }
int [] sync= new int[0];
  String att_code;
  int att_tailleclasse;
  int att_dep;
  TDS att_tds;
  TAM att_cpu;
  LEX_MJAVA att_scanner;
  String att_droith;
  LinkedList<TDS> att_tdsi;
  String glob_15_signature;
  String glob_14_signature;
  String glob_16_signature;
  private void regle14() throws Exception {
 offset = scanner.getOffset(0);

    //declaration
    S_TYPE_MJAVA x_2 = new S_TYPE_MJAVA(scanner) ;
    T_MJAVA x_3 = new T_MJAVA(scanner ) ;
    T_MJAVA x_4 = new T_MJAVA(scanner ) ;
    S_PARFS_MJAVA x_5 = new S_PARFS_MJAVA(scanner) ;
    T_MJAVA x_6 = new T_MJAVA(scanner ) ;
    S_BLOC_MJAVA x_8 = new S_BLOC_MJAVA(scanner) ;
    //appel
      action_auto_inh_14(x_2, x_3, x_5, x_8);
    x_2.analyser() ;
      addChild(x_2);
    x_3.analyser(LEX_MJAVA.token_ident);
      addChild(x_3);
    x_4.analyser(LEX_MJAVA.token_paro);
      addChild(x_4);
    x_5.analyser() ;
      addChild(x_5);
    x_6.analyser(LEX_MJAVA.token_parf);
      addChild(x_6);
      action_tds_14(x_2, x_3, x_5, x_8);
    x_8.analyser() ;
      addChild(x_8);
      action_code9_14(x_2, x_3, x_5, x_8);
     length =x_8.getOffset() + x_8.getLength()  -offset;
  }
  private void regle15() throws Exception {
 offset = scanner.getOffset(0);

    //declaration
    T_MJAVA x_2 = new T_MJAVA(scanner ) ;
    T_MJAVA x_3 = new T_MJAVA(scanner ) ;
    T_MJAVA x_4 = new T_MJAVA(scanner ) ;
    S_PARFS_MJAVA x_5 = new S_PARFS_MJAVA(scanner) ;
    T_MJAVA x_6 = new T_MJAVA(scanner ) ;
    S_BLOC_MJAVA x_8 = new S_BLOC_MJAVA(scanner) ;
    //appel
      action_auto_inh_15(x_3, x_5, x_8);
    x_2.analyser(LEX_MJAVA.token_void);
      addChild(x_2);
    x_3.analyser(LEX_MJAVA.token_ident);
      addChild(x_3);
    x_4.analyser(LEX_MJAVA.token_paro);
      addChild(x_4);
    x_5.analyser() ;
      addChild(x_5);
    x_6.analyser(LEX_MJAVA.token_parf);
      addChild(x_6);
      action_tds_15(x_3, x_5, x_8);
    x_8.analyser() ;
      addChild(x_8);
      action_code10_15(x_3, x_5, x_8);
     length =x_8.getOffset() + x_8.getLength()  -offset;
  }
  private void regle13() throws Exception {
 offset = scanner.getOffset(0);

    //declaration
    S_TYPE_MJAVA x_2 = new S_TYPE_MJAVA(scanner) ;
    T_MJAVA x_3 = new T_MJAVA(scanner ) ;
    T_MJAVA x_4 = new T_MJAVA(scanner ) ;
    //appel
      action_auto_inh_13(x_2, x_3);
    x_2.analyser() ;
      addChild(x_2);
    x_3.analyser(LEX_MJAVA.token_ident);
      addChild(x_3);
    x_4.analyser(LEX_MJAVA.token_pv);
      addChild(x_4);
      action_tds_13(x_2, x_3);
      action_code8_13(x_2, x_3);
     length =x_4.getOffset() + x_4.getLength()  -offset;
  }
  private void regle16() throws Exception {
 offset = scanner.getOffset(0);

    //declaration
    T_MJAVA x_2 = new T_MJAVA(scanner ) ;
    T_MJAVA x_3 = new T_MJAVA(scanner ) ;
    S_PARFS_MJAVA x_4 = new S_PARFS_MJAVA(scanner) ;
    T_MJAVA x_5 = new T_MJAVA(scanner ) ;
    S_BLOC_MJAVA x_7 = new S_BLOC_MJAVA(scanner) ;
    //appel
      action_auto_inh_16(x_2, x_4, x_7);
    x_2.analyser(LEX_MJAVA.token_ident);
      addChild(x_2);
    x_3.analyser(LEX_MJAVA.token_paro);
      addChild(x_3);
    x_4.analyser() ;
      addChild(x_4);
    x_5.analyser(LEX_MJAVA.token_parf);
      addChild(x_5);
      action_tds_16(x_2, x_4, x_7);
    x_7.analyser() ;
      addChild(x_7);
      action_code11_16(x_2, x_4, x_7);
     length =x_7.getOffset() + x_7.getLength()  -offset;
  }
private void action_code8_13(S_TYPE_MJAVA x_2, T_MJAVA x_3) throws Exception {
try {
// instructions
this.att_code=this.att_cpu.reserver_mem(x_2.att_type.getTaille());
}catch(RuntimeException e) {		//e.printStackTrace();
	}
  }
private void action_code11_16(T_MJAVA x_2, S_PARFS_MJAVA x_4, S_BLOC_MJAVA x_7) throws Exception {
try {
// locales
LinkedList<DTYPE> loc_pars;
// instructions
loc_pars=this.att_tds.getTypeParams(x_4.att_params);
}catch(RuntimeException e) {		//e.printStackTrace();
	}
  }
private void action_auto_inh_16(T_MJAVA x_2, S_PARFS_MJAVA x_4, S_BLOC_MJAVA x_7) throws Exception {
try {
// instructions
x_4.att_tds=this.att_tds;
x_4.att_tdsi=this.att_tdsi;
x_7.att_tdsi=this.att_tdsi;
x_4.att_dep=this.att_dep;
x_7.att_cpu=this.att_cpu;
}catch(RuntimeException e) {		//e.printStackTrace();
	}
  }
private void action_auto_inh_14(S_TYPE_MJAVA x_2, T_MJAVA x_3, S_PARFS_MJAVA x_5, S_BLOC_MJAVA x_8) throws Exception {
try {
// instructions
x_2.att_tds=this.att_tds;
x_5.att_tds=this.att_tds;
x_2.att_tdsi=this.att_tdsi;
x_5.att_tdsi=this.att_tdsi;
x_8.att_tdsi=this.att_tdsi;
x_5.att_dep=this.att_dep;
x_8.att_cpu=this.att_cpu;
}catch(RuntimeException e) {		//e.printStackTrace();
	}
  }
private void action_tds_13(S_TYPE_MJAVA x_2, T_MJAVA x_3) throws Exception {
try {
// locales
INFO loc_i;
// instructions
loc_i=this.att_tds.chercherGlobalement(x_3.att_txt);
if (loc_i==null){
    this.att_tds.inserer(x_3.att_txt,  new VAR(x_3.att_txt, this.att_dep, true, x_2.att_type, this.att_droith, null));
loc_i=this.att_tds.chercherGlobalement(x_3.att_txt);
this.att_tailleclasse=x_2.att_type.getTaille();
}
else {
att_scanner._interrompre(IProblem.Semantic, att_scanner.getBeginLine(), IMJAVAMessages.id_B_03, MJAVAMessages.B_03,new Object[]{""+x_3.att_txt});

}
}catch(RuntimeException e) {		//e.printStackTrace();
	}
  }
private void action_code9_14(S_TYPE_MJAVA x_2, T_MJAVA x_3, S_PARFS_MJAVA x_5, S_BLOC_MJAVA x_8) throws Exception {
try {
// locales
LinkedList<DTYPE> loc_pars;
// instructions
loc_pars=this.att_tds.getTypeParams(x_5.att_params);
this.att_code=this.att_cpu.genererEnTete(x_3.att_txt)+x_8.att_code+this.att_cpu.genererFinFonction(x_2.att_type.getTaille(), loc_pars);
}catch(RuntimeException e) {		//e.printStackTrace();
	}
  }
private void action_tds_15(T_MJAVA x_3, S_PARFS_MJAVA x_5, S_BLOC_MJAVA x_8) throws Exception {
try {
// locales
METHODE loc_i;
INFO loc_itps;
LinkedList<DTYPE> loc_pars;
// instructions
loc_i=null;
loc_pars=this.att_tds.getTypeParams(x_5.att_params);
glob_15_signature=this.att_tds.getSignature(this.att_tds.getNom(), x_3.att_txt, loc_pars);
loc_itps=this.att_tds.chercherGlobalement(glob_15_signature);
if (loc_itps instanceof METHODE ){
loc_i=((METHODE)loc_itps);
}

if (loc_i==null){
    this.att_tds.inserer(glob_15_signature,  new METHODE(x_3.att_txt, 0, true,  new DTYPE("void", 0), x_5.att_params));
}
else {
if (this.att_tds.getParent()==null){
att_scanner._interrompre(IProblem.Semantic, att_scanner.getBeginLine(), IMJAVAMessages.id_B_04, MJAVAMessages.B_04,new Object[]{""+x_3.att_txt});

}
else {
    this.att_tds.inserer(glob_15_signature,  new METHODE(x_3.att_txt, 0, true,  new DTYPE("void", 0), x_5.att_params));
}
}
x_8.att_tds= new TDS(this.att_tds, x_5.att_params, x_3.att_txt);
x_8.att_dep=x_5.att_deps;
this.att_tailleclasse=0;
}catch(RuntimeException e) {		//e.printStackTrace();
	}
  }
private void action_tds_16(T_MJAVA x_2, S_PARFS_MJAVA x_4, S_BLOC_MJAVA x_7) throws Exception {
try {
// locales
METHODE loc_i;
INFO loc_j;
INFO loc_itps;
LinkedList<DTYPE> loc_pars;
String loc_nomclasse;
DTYPE loc_type;
// instructions
loc_j=this.att_tds.chercherLocalement(this.att_tds.getNom());
loc_type=loc_j.getType();
    loc_type.setTaille(this.att_dep);
loc_nomclasse=this.att_tds.getNom();
loc_i=null;
loc_pars=this.att_tds.getTypeParams(x_4.att_params);
loc_j=this.att_tds.chercherGlobalement(loc_nomclasse);
if (loc_nomclasse.equals(x_2.att_txt)){
glob_16_signature=this.att_tds.getSignature(this.att_tds.getNom(), x_2.att_txt, loc_pars);
loc_itps=this.att_tds.chercherGlobalement(glob_16_signature);
if (loc_itps instanceof METHODE ){
loc_i=((METHODE)loc_itps);
}

if (loc_i==null){
    this.att_tds.inserer(glob_16_signature,  new METHODE(x_2.att_txt, 0, true,  new DTYPE(loc_nomclasse, loc_j.getTailleType()), x_4.att_params));
}
else {
att_scanner._interrompre(IProblem.Semantic, att_scanner.getBeginLine(), IMJAVAMessages.id_B_05, MJAVAMessages.B_05,new Object[]{""+x_2.att_txt});

}
x_7.att_tds= new TDS(this.att_tds, x_4.att_params, x_2.att_txt);
x_7.att_dep=x_4.att_deps;
this.att_tailleclasse=0;
}
else {
att_scanner._interrompre(IProblem.Semantic, att_scanner.getBeginLine(), IMJAVAMessages.id_B_06, MJAVAMessages.B_06,new Object[]{""+x_2.att_txt});

}
}catch(RuntimeException e) {		//e.printStackTrace();
	}
  }
private void action_auto_inh_15(T_MJAVA x_3, S_PARFS_MJAVA x_5, S_BLOC_MJAVA x_8) throws Exception {
try {
// instructions
x_5.att_tds=this.att_tds;
x_5.att_tdsi=this.att_tdsi;
x_8.att_tdsi=this.att_tdsi;
x_5.att_dep=this.att_dep;
x_8.att_cpu=this.att_cpu;
}catch(RuntimeException e) {		//e.printStackTrace();
	}
  }
private void action_auto_inh_13(S_TYPE_MJAVA x_2, T_MJAVA x_3) throws Exception {
try {
// instructions
x_2.att_tds=this.att_tds;
x_2.att_tdsi=this.att_tdsi;
}catch(RuntimeException e) {		//e.printStackTrace();
	}
  }
private void action_code10_15(T_MJAVA x_3, S_PARFS_MJAVA x_5, S_BLOC_MJAVA x_8) throws Exception {
try {
// locales
LinkedList<DTYPE> loc_pars;
// instructions
loc_pars=this.att_tds.getTypeParams(x_5.att_params);
this.att_code=this.att_cpu.genererEnTete(x_3.att_txt)+x_8.att_code+this.att_cpu.genererFinFonction(0, loc_pars);
}catch(RuntimeException e) {		//e.printStackTrace();
	}
  }
private void action_tds_14(S_TYPE_MJAVA x_2, T_MJAVA x_3, S_PARFS_MJAVA x_5, S_BLOC_MJAVA x_8) throws Exception {
try {
// locales
METHODE loc_i;
INFO loc_itps;
LinkedList<DTYPE> loc_pars;
// instructions
loc_i=null;
loc_pars=this.att_tds.getTypeParams(x_5.att_params);
glob_14_signature=this.att_tds.getSignature(this.att_tds.getNom(), x_3.att_txt, loc_pars);
loc_itps=this.att_tds.chercherGlobalement(glob_14_signature);
if (loc_itps instanceof METHODE ){
loc_i=((METHODE)loc_itps);
}

if (loc_i==null){
    this.att_tds.inserer(glob_14_signature,  new METHODE(x_3.att_txt, 0, true, x_2.att_type, x_5.att_params));
}
else {
if (this.att_tds.getParent()==null){
att_scanner._interrompre(IProblem.Semantic, att_scanner.getBeginLine(), IMJAVAMessages.id_B_04, MJAVAMessages.B_04,new Object[]{""+x_3.att_txt});

}
else {
    this.att_tds.inserer(glob_14_signature,  new METHODE(x_3.att_txt, 0, true, x_2.att_type, x_5.att_params));
}
}
x_8.att_tds= new TDS(this.att_tds, x_5.att_params, x_3.att_txt);
this.att_tailleclasse=0;
x_8.att_dep=x_5.att_deps;
}catch(RuntimeException e) {		//e.printStackTrace();
	}
  }
  public void analyser () throws Exception {
    scanner.lit ( 1 ) ;
    switch ( scanner.fenetre[0].code ) {
      case LEX_MJAVA.token_int : // 45460
        scanner.lit ( 2 ) ;
        switch ( scanner.fenetre[1].code ) {
          case LEX_MJAVA.token_ident : // 45490
            scanner.lit ( 3 ) ;
            switch ( scanner.fenetre[2].code ) {
              case LEX_MJAVA.token_pv : // 45453
                regle13 () ;
              break ;
              case LEX_MJAVA.token_paro : // 45446
                regle14 () ;
              break ;
              default :
                       scanner._interrompre(IProblem.Syntax, scanner.getBeginLine(), IMJAVAMessages.id_MJAVA_unexpected_token,MJAVAMessages.MJAVA_unexpected_token,new String[]{scanner.fenetre[2].getNom()});
scanner.accepter_sucre(LEX_MJAVA.token_ident);
            }
          break ;
          default :
                   scanner._interrompre(IProblem.Syntax, scanner.getBeginLine(), IMJAVAMessages.id_MJAVA_unexpected_token,MJAVAMessages.MJAVA_unexpected_token,new String[]{scanner.fenetre[1].getNom()});
scanner.accepter_sucre(LEX_MJAVA.token_int);
        }
      break ;
      case LEX_MJAVA.token_bool : // 45461
        scanner.lit ( 2 ) ;
        switch ( scanner.fenetre[1].code ) {
          case LEX_MJAVA.token_ident : // 45490
            scanner.lit ( 3 ) ;
            switch ( scanner.fenetre[2].code ) {
              case LEX_MJAVA.token_pv : // 45453
                regle13 () ;
              break ;
              case LEX_MJAVA.token_paro : // 45446
                regle14 () ;
              break ;
              default :
                       scanner._interrompre(IProblem.Syntax, scanner.getBeginLine(), IMJAVAMessages.id_MJAVA_unexpected_token,MJAVAMessages.MJAVA_unexpected_token,new String[]{scanner.fenetre[2].getNom()});
scanner.accepter_sucre(LEX_MJAVA.token_ident);
            }
          break ;
          default :
                   scanner._interrompre(IProblem.Syntax, scanner.getBeginLine(), IMJAVAMessages.id_MJAVA_unexpected_token,MJAVAMessages.MJAVA_unexpected_token,new String[]{scanner.fenetre[1].getNom()});
scanner.accepter_sucre(LEX_MJAVA.token_bool);
        }
      break ;
      case LEX_MJAVA.token_ident : // 45490
        scanner.lit ( 2 ) ;
        switch ( scanner.fenetre[1].code ) {
          case LEX_MJAVA.token_ident : // 45490
            scanner.lit ( 3 ) ;
            switch ( scanner.fenetre[2].code ) {
              case LEX_MJAVA.token_pv : // 45453
                regle13 () ;
              break ;
              case LEX_MJAVA.token_paro : // 45446
                regle14 () ;
              break ;
              default :
                       scanner._interrompre(IProblem.Syntax, scanner.getBeginLine(), IMJAVAMessages.id_MJAVA_unexpected_token,MJAVAMessages.MJAVA_unexpected_token,new String[]{scanner.fenetre[2].getNom()});
scanner.accepter_sucre(LEX_MJAVA.token_ident);
            }
          break ;
          case LEX_MJAVA.token_paro : // 45446
            regle16 () ;
          break ;
          default :
                   scanner._interrompre(IProblem.Syntax, scanner.getBeginLine(), IMJAVAMessages.id_MJAVA_unexpected_token,MJAVAMessages.MJAVA_unexpected_token,new String[]{scanner.fenetre[1].getNom()});
scanner.accepter_sucre(LEX_MJAVA.token_ident);
        }
      break ;
      case LEX_MJAVA.token_void : // 45459
        regle15 () ;
      break ;
      default :
               scanner._interrompre(IProblem.Syntax, scanner.getBeginLine(), IMJAVAMessages.id_MJAVA_unexpected_token,MJAVAMessages.MJAVA_unexpected_token,new String[]{scanner.fenetre[0].getNom()});
    }
  }
    private IDstNode parent;
    public void setParent( IDstNode p){parent = p;}
    public IDstNode getParent(){return parent;}
    private List<IDstNode> children = null ;
    public void addChild(IDstNode node){
      if (children == null) {
         children = new ArrayList<IDstNode>() ;}
      children.add(node);
      node.setParent(this);
    }
    public List<IDstNode> getChildren(){return children;}
    public boolean isLeaf(){return children == null;}
    public void accept(IDstVisitor visitor) {
      boolean visitChildren = visitor.visit(this);
      if (visitChildren && children != null){
        for(IDstNode node : children){
          node.accept(visitor);
        }
    }
    visitor.endVisit(this);
  }
  private int offset;
  private int length;
  public int getOffset(){return offset;}
  public void setOffset(int o){offset = o;}
  public int getLength(){return length;}
  public void setLength(int l){length = l;}
  private boolean malformed = false;
  public void setMalformed(){malformed = true;}
  public boolean isMalformed(){return malformed;}
  }
